package com.zw.yzk.kabu.data.repository;

import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.LogisticsEntity;
import com.zw.yzk.kabu.data.network.service.LogisticsService;
import com.zw.yzk.kabu.data.network.task.LogisticsTask;
import com.zw.yzk.kabu.data.network.task.Task;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2017/1/12.
 */

public class LogisticsRepository extends CommonRepository {

    @Inject
    public LogisticsRepository() {
    }


    @Override
    protected Observable connectServer(Task task) {
        LogisticsService service = ServiceGenerator.createService(LogisticsService.class);
        LogisticsTask logisticsTask = (LogisticsTask) task;
        logisticsTask.userId = null;
        logisticsTask.accessToken = null;

        return service.getLogistic(logisticsTask);
    }

    @Override
    protected Func1<LogisticsEntity, Observable> getServerData() {
        return new Func1<LogisticsEntity, Observable>() {
            @Override
            public Observable call(LogisticsEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
